/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * pnfMantenimientoProveedores.java
 *
 * Created on 18/10/2011, 03:56:07 PM
 */

package visual.Ingreso;

import bentity.beCombo;
import bentity.beProducto;
import bentity.beProveedor;
import bentity.beUsuario;
import blogic.blHelper;
import blogic.blLog;
import blogic.blProducto;
import blogic.blProveedor;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.io.FileOutputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.Document;
import visual.Seguridad.visualHelper;
/**
 *
 * @author giulio
 */
public class pnfMantenimientoProveedores extends javax.swing.JPanel {
    DefaultTableModel dtm;
    beUsuario usuario=null;


    /** Creates new form pnfMantenimientoProveedores */
    public pnfMantenimientoProveedores(beUsuario usuario) {
        initComponents();

        this.usuario=usuario;

        try{
            this.dtm = (DefaultTableModel)this.tblProveedores.getModel();
            this.dtm.setNumRows(0);

        }catch(Exception e){}
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblCosto = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblProveedores = new javax.swing.JTable();
        lblTitulo = new javax.swing.JLabel();
        pnlBusqueda = new javax.swing.JPanel();
        txtRuc = new javax.swing.JTextField();
        btnBuscar = new javax.swing.JButton();
        txtEmail = new javax.swing.JTextField();
        lblRuc = new javax.swing.JLabel();
        lblEmail = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        lblDireccion = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();
        lblTelefono = new javax.swing.JLabel();
        txtContacto = new javax.swing.JTextField();
        lblContacto = new javax.swing.JLabel();
        txtRazonSocial = new javax.swing.JTextField();
        lblRazonSocial4 = new javax.swing.JLabel();
        btnRegistrar = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        lblTablaProductos = new javax.swing.JLabel();

        setLayout(null);

        lblCosto.setFont(new java.awt.Font("Dialog", 0, 12));
        lblCosto.setForeground(new java.awt.Color(0, 0, 0));
        add(lblCosto);
        lblCosto.setBounds(381, 125, 0, 0);

        tblProveedores.setAutoCreateRowSorter(true);
        tblProveedores.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        tblProveedores.setForeground(new java.awt.Color(0, 0, 0));
        tblProveedores.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Codigo", "Razon Social", "RUC", "Direccion", "Telefono", "Email"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblProveedores.setColumnSelectionAllowed(true);
        tblProveedores.setGridColor(javax.swing.UIManager.getDefaults().getColor("TableHeader.background"));
        tblProveedores.setMaximumSize(new java.awt.Dimension(800, 72));
        tblProveedores.setMinimumSize(new java.awt.Dimension(200, 72));
        tblProveedores.setSelectionForeground(new java.awt.Color(0, 0, 0));
        tblProveedores.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tblProveedores.getTableHeader().setReorderingAllowed(false);
        tblProveedores.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                tblProveedoresFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                tblProveedoresFocusLost(evt);
            }
        });
        jScrollPane2.setViewportView(tblProveedores);
        tblProveedores.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        add(jScrollPane2);
        jScrollPane2.setBounds(110, 260, 750, 170);

        lblTitulo.setFont(new java.awt.Font("Dialog", 0, 36));
        lblTitulo.setForeground(new java.awt.Color(0, 0, 0));
        lblTitulo.setText("Mantenimiento de proveedores");
        add(lblTitulo);
        lblTitulo.setBounds(200, 10, 564, 43);

        pnlBusqueda.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Busqueda", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 14))); // NOI18N
        pnlBusqueda.setLayout(null);

        txtRuc.setFont(new java.awt.Font("Dialog", 0, 12));
        txtRuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtRucActionPerformed(evt);
            }
        });
        txtRuc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtRucKeyTyped(evt);
            }
        });
        pnlBusqueda.add(txtRuc);
        txtRuc.setBounds(120, 60, 183, 25);

        btnBuscar.setBackground(new java.awt.Color(240, 235, 226));
        btnBuscar.setFont(new java.awt.Font("Dialog", 0, 12));
        btnBuscar.setForeground(new java.awt.Color(0, 0, 0));
        btnBuscar.setText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });
        pnlBusqueda.add(btnBuscar);
        btnBuscar.setBounds(560, 140, 120, 27);

        txtEmail.setFont(new java.awt.Font("Dialog", 0, 12));
        txtEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtEmailActionPerformed(evt);
            }
        });
        txtEmail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtEmailKeyTyped(evt);
            }
        });
        pnlBusqueda.add(txtEmail);
        txtEmail.setBounds(500, 100, 183, 25);

        lblRuc.setFont(new java.awt.Font("Dialog", 0, 12));
        lblRuc.setForeground(new java.awt.Color(0, 0, 0));
        lblRuc.setText("RUC");
        pnlBusqueda.add(lblRuc);
        lblRuc.setBounds(20, 70, 25, 15);

        lblEmail.setFont(new java.awt.Font("Dialog", 0, 12));
        lblEmail.setForeground(new java.awt.Color(0, 0, 0));
        lblEmail.setText("E-mail");
        pnlBusqueda.add(lblEmail);
        lblEmail.setBounds(400, 110, 90, 15);

        txtDireccion.setFont(new java.awt.Font("Dialog", 0, 12));
        txtDireccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDireccionActionPerformed(evt);
            }
        });
        txtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDireccionKeyTyped(evt);
            }
        });
        pnlBusqueda.add(txtDireccion);
        txtDireccion.setBounds(120, 100, 183, 25);

        lblDireccion.setFont(new java.awt.Font("Dialog", 0, 12));
        lblDireccion.setForeground(new java.awt.Color(0, 0, 0));
        lblDireccion.setText("Direccion");
        pnlBusqueda.add(lblDireccion);
        lblDireccion.setBounds(20, 110, 90, 15);

        txtTelefono.setFont(new java.awt.Font("Dialog", 0, 12));
        txtTelefono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTelefonoActionPerformed(evt);
            }
        });
        txtTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtTelefonoKeyTyped(evt);
            }
        });
        pnlBusqueda.add(txtTelefono);
        txtTelefono.setBounds(500, 20, 183, 25);

        lblTelefono.setFont(new java.awt.Font("Dialog", 0, 12));
        lblTelefono.setForeground(new java.awt.Color(0, 0, 0));
        lblTelefono.setText("Telefono");
        pnlBusqueda.add(lblTelefono);
        lblTelefono.setBounds(400, 30, 90, 15);

        txtContacto.setFont(new java.awt.Font("Dialog", 0, 12));
        txtContacto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtContactoActionPerformed(evt);
            }
        });
        txtContacto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtContactoKeyTyped(evt);
            }
        });
        pnlBusqueda.add(txtContacto);
        txtContacto.setBounds(500, 60, 183, 25);

        lblContacto.setFont(new java.awt.Font("Dialog", 0, 12));
        lblContacto.setForeground(new java.awt.Color(0, 0, 0));
        lblContacto.setText("Contacto");
        pnlBusqueda.add(lblContacto);
        lblContacto.setBounds(400, 70, 90, 15);

        txtRazonSocial.setFont(new java.awt.Font("Dialog", 0, 12));
        txtRazonSocial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtRazonSocialActionPerformed(evt);
            }
        });
        txtRazonSocial.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtRazonSocialKeyTyped(evt);
            }
        });
        pnlBusqueda.add(txtRazonSocial);
        txtRazonSocial.setBounds(120, 20, 183, 25);

        lblRazonSocial4.setFont(new java.awt.Font("Dialog", 0, 12));
        lblRazonSocial4.setForeground(new java.awt.Color(0, 0, 0));
        lblRazonSocial4.setText("Razon Social");
        pnlBusqueda.add(lblRazonSocial4);
        lblRazonSocial4.setBounds(20, 30, 90, 15);

        add(pnlBusqueda);
        pnlBusqueda.setBounds(110, 60, 750, 180);

        btnRegistrar.setBackground(new java.awt.Color(240, 235, 226));
        btnRegistrar.setFont(new java.awt.Font("Dialog", 0, 12));
        btnRegistrar.setForeground(new java.awt.Color(0, 0, 0));
        btnRegistrar.setText("Registrar");
        btnRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistrarActionPerformed(evt);
            }
        });
        add(btnRegistrar);
        btnRegistrar.setBounds(190, 450, 120, 27);

        btnModificar.setBackground(new java.awt.Color(240, 235, 226));
        btnModificar.setFont(new java.awt.Font("Dialog", 0, 12));
        btnModificar.setForeground(new java.awt.Color(0, 0, 0));
        btnModificar.setText("Modificar");
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });
        add(btnModificar);
        btnModificar.setBounds(410, 450, 130, 27);

        btnEliminar.setBackground(new java.awt.Color(240, 235, 226));
        btnEliminar.setFont(new java.awt.Font("Dialog", 0, 12));
        btnEliminar.setForeground(new java.awt.Color(0, 0, 0));
        btnEliminar.setText("Eliminar");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });
        add(btnEliminar);
        btnEliminar.setBounds(630, 450, 120, 27);

        lblTablaProductos.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N
        lblTablaProductos.setForeground(new java.awt.Color(0, 0, 0));
        lblTablaProductos.setText("Proveedores");
        add(lblTablaProductos);
        lblTablaProductos.setBounds(110, 240, 160, 15);
    }// </editor-fold>//GEN-END:initComponents

    private void btnRegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarActionPerformed
        dlgRegistroProveedores dlgRegProv= new dlgRegistroProveedores(null, true,usuario);
        dlgRegProv.setVisible(true);

}//GEN-LAST:event_btnRegistrarActionPerformed

    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
        int idProveedor=-1;
        int indice=-1;

        if(this.tblProveedores.getSelectedRow()==-1) return;

        try{

            indice= this.tblProveedores.getSelectedRow();

            if(indice<0) return;

       
            idProveedor=Integer.parseInt(this.tblProveedores.getValueAt(indice, 0).toString());

        
            dlgModificarProveedor dlgModProv= new dlgModificarProveedor(null, true,idProveedor,usuario);
            dlgModProv.setVisible(true);


            this.buscarYMostrar();

        }catch(Exception e){
            return;
        }
}//GEN-LAST:event_btnModificarActionPerformed

    private void txtEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtEmailActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtEmailActionPerformed

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        int idProveedor=-1;
        String nombreProveedor="";
        int indice=-1;



        try{

            indice= this.tblProveedores.getSelectedRow();

            if(indice<0) return;
   
            idProveedor=Integer.parseInt(this.tblProveedores.getValueAt(indice, 0).toString());
            nombreProveedor=this.tblProveedores.getValueAt(indice, 1).toString();

            int cantProds=(new blProveedor().cantidadDeProductosDeUnProveedor(idProveedor));

            if(cantProds>0){
                visualHelper.mostrarMensajeAdvertencia("No se puede eliminar el proveedor porque tiene productos asignados.");
                return;
            }

            int rslt=visualHelper.mostrarPreguntaSiNo("¿Está seguro que desea eliminar el proveedor "+nombreProveedor+" con código "+idProveedor+"?");
            if (rslt == JOptionPane.NO_OPTION)
            return;

            (new blProveedor()).eliminarProducto(idProveedor);
            int rLog=(new blLog().registrarLog(usuario.getIdUsuario(), usuario.getCargo(), "Se ha eliminado el proveedor "+idProveedor));

            visualHelper.mostrarMensajeSatisfaccion("Se ha eliminado el proveedor "+nombreProveedor+" con código "+idProveedor+" satisfactoriamente.");

            this.buscarYMostrar();

        }catch(Exception e){
            visualHelper.mostrarMensajeError("Ha ocurrido un error, inténtelo nuevamente.");
            return;
        }

    }//GEN-LAST:event_btnEliminarActionPerformed

    private void txtDireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDireccionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDireccionActionPerformed

    private void txtTelefonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTelefonoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtTelefonoActionPerformed

    private void txtContactoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtContactoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtContactoActionPerformed

    private void txtRazonSocialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtRazonSocialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtRazonSocialActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        
        try {
            buscarYMostrar();

        } catch (Exception e) {
            e.printStackTrace();
            visualHelper.mostrarMensajeError("Ha ocurrido un error en la búsqueda. Inténtelo nuevamente");
        }
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void tblProveedoresFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tblProveedoresFocusGained
//        this.cambiarEstadoBotones(true);
    }//GEN-LAST:event_tblProveedoresFocusGained

    private void tblProveedoresFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tblProveedoresFocusLost
//        this.cambiarEstadoBotones(false);
    }//GEN-LAST:event_tblProveedoresFocusLost

    private void txtRucKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRucKeyTyped

        String strRuc = this.txtRuc.getText();
        if (strRuc.length() == 11)
            visualHelper.ningunCaracterEnTextField(evt);
        else
            visualHelper.soloDigitosEnTextField(evt);
    }//GEN-LAST:event_txtRucKeyTyped

    private void txtTelefonoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelefonoKeyTyped
        String strTelf = this.txtTelefono.getText();
        if (strTelf.length() >= 20)
            visualHelper.ningunCaracterEnTextField(evt);
        else
        visualHelper.validarTelefono(evt);
    }//GEN-LAST:event_txtTelefonoKeyTyped

    private void txtEmailKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEmailKeyTyped
        String strEmail = this.txtEmail.getText();
        if (strEmail.length() >= 30)
            visualHelper.ningunCaracterEnTextField(evt);
        else
            visualHelper.soloNombres(evt);
    }//GEN-LAST:event_txtEmailKeyTyped

    private void txtRucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtRucActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtRucActionPerformed

    private void txtRazonSocialKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRazonSocialKeyTyped
        String strRazon = this.txtRazonSocial.getText();
        if (strRazon.length() >= 50)
            visualHelper.ningunCaracterEnTextField(evt);
        else
            visualHelper.soloNombres(evt);
    }//GEN-LAST:event_txtRazonSocialKeyTyped

    private void txtContactoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtContactoKeyTyped
        String strContacto = this.txtContacto.getText();
        if (strContacto.length() >= 50)
            visualHelper.ningunCaracterEnTextField(evt);
        else
            visualHelper.soloNombres(evt);
    }//GEN-LAST:event_txtContactoKeyTyped

    private void txtDireccionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDireccionKeyTyped
        String strDireccion = this.txtDireccion.getText();
        if (strDireccion.length() >= 200)
            visualHelper.ningunCaracterEnTextField(evt);
        else
            visualHelper.soloNombres(evt);
    }//GEN-LAST:event_txtDireccionKeyTyped


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnRegistrar;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblContacto;
    private javax.swing.JLabel lblCosto;
    private javax.swing.JLabel lblDireccion;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblRazonSocial4;
    private javax.swing.JLabel lblRuc;
    private javax.swing.JLabel lblTablaProductos;
    private javax.swing.JLabel lblTelefono;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JPanel pnlBusqueda;
    private javax.swing.JTable tblProveedores;
    private javax.swing.JTextField txtContacto;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtRazonSocial;
    private javax.swing.JTextField txtRuc;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables

    private ArrayList<beProveedor> buscarProveedores() throws Exception{

        blHelper blh=new blHelper();

        String razonProveedor="";
        String rucProveedor="";
        String direccionProveedor="";
        String contactoProveedor="";
        String emailProveedor="";
        String telefonoProveedor="";


        ArrayList<beProveedor> listaProductos=new ArrayList<beProveedor>();

        if(!this.txtTelefono.getText().equals("")){
            visualHelper.mostrarMensajeAdvertencia("El campo teléfono solo puede contener carácteres numéricos");
            return null;
        }

        if(!this.txtRuc.getText().equals("") && !blh.caracteresSoloDigitos(this.txtRuc.getText())){
            visualHelper.mostrarMensajeAdvertencia("El campo Ruc solo puede contener carácteres numéricos");
            return null;
        }


        if(!this.txtRazonSocial.getText().equals("")) razonProveedor=this.txtRazonSocial.getText();
        if(!this.txtRuc.getText().equals("")) rucProveedor=this.txtRuc.getText();
        if(!this.txtDireccion.getText().equals("")) direccionProveedor=this.txtDireccion.getText();
        if(!this.txtContacto.getText().equals("")) contactoProveedor=this.txtContacto.getText();
        if(!this.txtEmail.getText().equals("")) emailProveedor=this.txtEmail.getText();
        if(!this.txtTelefono.getText().equals("")) telefonoProveedor=this.txtTelefono.getText();

        listaProductos=(new blProveedor()).busquedaProveedorBL(razonProveedor,rucProveedor,direccionProveedor,contactoProveedor,emailProveedor,telefonoProveedor);


        return listaProductos;

    }

    private void mostrarProductos(ArrayList<beProveedor> listaProveedores) throws Exception{


        if(listaProveedores==null) return;

        limpiarTabla();
        Object [] datos = new Object [6];


        for(int i=0;i<listaProveedores.size();i++){
            datos[0] = listaProveedores.get(i).getId_Proveedor();
            datos[1] = listaProveedores.get(i).getRazon_Social();
            datos[2] = listaProveedores.get(i).getRuc();
            datos[3] = (listaProveedores.get(i).getDireccion().equals(""))? "No especifica" :  listaProveedores.get(i).getDireccion();
            datos[4] = (listaProveedores.get(i).getTelefono().equals(""))?  "No especifica" : listaProveedores.get(i).getTelefono();
            datos[5] = (listaProveedores.get(i).getEmail().equals(""))? "No especifica" : listaProveedores.get(i).getEmail();
            dtm.addRow(datos);
        }
        this.tblProveedores.setRowSelectionAllowed(true);
        this.tblProveedores.setColumnSelectionAllowed(false);


    }

    private void cambiarEstadoBotones(boolean b) {
        this.btnModificar.setEnabled(b);
        this.btnEliminar.setEnabled(b);
    }

    private void buscarYMostrar() throws Exception{
        ArrayList<beProveedor> listaProductos=new ArrayList<beProveedor>();
        listaProductos = buscarProveedores();

        if (listaProductos==null || listaProductos.size()==0) {
            limpiarTabla();
            visualHelper.mostrarMensajeAdvertencia("No se encontraron proveedores con los parámetros ingresados.");
            return;
        }
        mostrarProductos(listaProductos);
    }

    private void limpiarTabla() {
        for(int i=0;i<=dtm.getRowCount()-1;){
            dtm.removeRow(0);
        }
    }

}
